﻿using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows;

namespace DSSDataServiceGenerator.Model
{
    class XObject
        : INotifyPropertyChanged
    {
        public XObject()
            : base()
        {
            this.PropertyChanged += XObject_PropertyChanged;
        }

        public event PropertyChangedEventHandler PropertyChanged;

        private void XObject_PropertyChanged(object sender, PropertyChangedEventArgs e)
        { }

        protected bool IsFreezed { get; private set; }

        protected void Freeze()
        {
            this.IsFreezed = true;
        }

        protected void Release()
        { 
            this.IsFreezed = false;

            this.OnPropertyChanged(null);
        }

        protected void OnPropertyChanged(string name)
        {
            if (this.IsFreezed) return;

            this.OnPropertyChanged();

            if (this.PropertyChanged != null)

                this.PropertyChanged(this, new PropertyChangedEventArgs(name));
        }

        protected virtual void OnPropertyChanged()
        { }
    }
}
